/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package models;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Eduardo
 */
@Entity
@Table(name = "Estante")
@NamedQueries({
    @NamedQuery(name = "Estante.findAll", query = "SELECT e FROM Estante e"),
    @NamedQuery(name = "Estante.findByIdEstante", query = "SELECT e FROM Estante e WHERE e.idEstante = :idEstante"),
    @NamedQuery(name = "Estante.findByCapacidad", query = "SELECT e FROM Estante e WHERE e.capacidad = :capacidad"),
    @NamedQuery(name = "Estante.findByEstado", query = "SELECT e FROM Estante e WHERE e.estado = :estado")})
public class Estante implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idEstante")
    private Integer idEstante;
    @Column(name = "Capacidad")
    private Integer capacidad;
    @Column(name = "Estado")
    private Integer estado;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idEstante", fetch = FetchType.LAZY)
    private List<Ejemplar> ejemplarList;
    @JoinColumn(name = "IdZona", referencedColumnName = "IdZona")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Zona idZona;

    public Estante() {
    }

    public Estante(Integer idEstante) {
        this.idEstante = idEstante;
    }

    public Integer getIdEstante() {
        return idEstante;
    }

    public void setIdEstante(Integer idEstante) {
        this.idEstante = idEstante;
    }

    public Integer getCapacidad() {
        return capacidad;
    }

    public void setCapacidad(Integer capacidad) {
        this.capacidad = capacidad;
    }

    public Integer getEstado() {
        return estado;
    }

    public void setEstado(Integer estado) {
        this.estado = estado;
    }

    public List<Ejemplar> getEjemplarList() {
        return ejemplarList;
    }

    public void setEjemplarList(List<Ejemplar> ejemplarList) {
        this.ejemplarList = ejemplarList;
    }

    public Zona getIdZona() {
        return idZona;
    }

    public void setIdZona(Zona idZona) {
        this.idZona = idZona;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idEstante != null ? idEstante.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Estante)) {
            return false;
        }
        Estante other = (Estante) object;
        if ((this.idEstante == null && other.idEstante != null) || (this.idEstante != null && !this.idEstante.equals(other.idEstante))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "models.Estante[ idEstante=" + idEstante + " ]";
    }
    
}
